package luogu;

import java.io.*;
import java.util.Scanner;

public class A4017P2 {
    static int[] h;
    static int[] e;
    static int[] ne;
    static int idx=1;
    static int[] vis;
    static int n;
    static int m;
    static int[] d;//入度
    static int[] up;//出度
    static int res=0;//食物链数
    static int[] path;
    static final int MOD= 80112002;
    static final int N=500050;
    static void add(int a,int b){
        e[idx]=b;
        ne[idx]=h[a];
        h[a]=idx++;
    }
    static void topo(){
        int[] q=new int[n+10];
        int hh=0,tt=-1;
        //将入度为0的点加入队列
        for(int i=1;i<=n;i++){
            if(d[i]==0){
                path[i]=1;
                q[++tt]=i;
            }
        }
        while(hh<=tt){
            int head=q[hh++];
            //枚举该点的边
            for(int edge=h[head];edge!=0;edge=ne[edge]){
                int end=e[edge];
                path[end]=(path[head]+path[end])%MOD;
                d[end]--;//入度减1
                if(d[end]==0)q[++tt]=end;
            }
        }
        for(int i=1;i<=n;i++){
            if(up[i]==0)res+=path[i];
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter log=new BufferedWriter(new OutputStreamWriter(System.out));
        String[] params = br.readLine().split(" ");
        n = Integer.parseInt(params[0]);
        m = Integer.parseInt(params[1]);

        h=new int[n+5];
        vis=new int[n+5];
        d=new int[n+5];
        e=new int[N];
        ne=new int[N];
        up=new int[n+5];
        path=new int[n+5];
        for(int i=1; i<=m; i++){
            String[] edge = br.readLine().split(" ");
            int a = Integer.parseInt(edge[0]);
            int b = Integer.parseInt(edge[1]);
            add(a,b);
            d[b]++;
            up[a]++;
        }
      topo();
        log.write(Integer.toString(res%MOD));
        log.flush();

    }
}
